package com.etc.service.impl;

import com.etc.dao.AdminDao;
import com.etc.dao.CustomerDao;
import com.etc.dao.impl.AdminDaoImpl;
import com.etc.dao.impl.CustomerDaoImpl;
import com.etc.entity.Admin;
import com.etc.entity.Customer;
import com.etc.service.LoginService;

public class LoginServiceImpl implements LoginService{
	private CustomerDao customerDao = new CustomerDaoImpl();
	private AdminDao adminDao = new AdminDaoImpl();
	/**
	 * 通过电话和密码查询
	 */
	@Override
	public Object login(String mobile, String password, Integer role) {
		// 根据参数role区别管理员，商家，用户的登录
		if (role == 1) {
			// 管理员登录
			System.out.println(mobile);
			System.out.println(password);
			Admin admin = adminDao.getAdmin(mobile, password);
			return admin;
			
		}else if (role == 2) {
			// 商家登录
			
			return null;
		}else if (role == 3) {
			// 用户登录
			Customer customer = customerDao.findByMobileAndPassword(mobile, password);
			return customer;
		}
		
		return null;
	}

}
